home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
filutil
/
direxe.zip
/
RUNEXE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-12
|
5KB
|
131 lines
#include <dirent.h> /* pour les fonctions opendir,readdir ... */
#include <string.h> /* pour la fonction strstr */
#include <stdio.h> /* pour printf */
#include <stdlib.h> /* pour exit */
#include <conio.h> /* pour wherex,wherey,getch */
#include <process.h> /* pour spawnl */
#define EXE 0
#define COM 1
#define BAT 2
#define MAXEXE 100 /* nbr max d'entree dans la table des pointeurs */
#define MAXLIN 25 /* nbr de ligne ecran geree par mon prog */
#define MAXCOL 5 /* 5 fichier par ligne (5*16=80) */
void main () {
DIR *dirdes ;
struct dirent *filedes ;
const char *line = "────────────────────────────────────────────────────────────────────────────────" ;
int i , j , nbr [3] = {0,0,0} ;
char *p [3][MAXEXE] ; /* tableau a 2 dim de pointeur vers des string */
char *q [MAXLIN][MAXCOL] ; /* idem */
int actline , actcol , touche , badnumber , badline [4] = {0,0,0,0} ;
/* ouvre le flux du dir courant */
if ((dirdes = opendir (".")) == NULL) {
printf ("Warning, can't open the directory !!!") ;
exit (1) ;
}
/* ATTENTION, DOS RENVOIE LES NOMS DE DIR. EN MAJUSCULES */
while ((filedes = readdir (dirdes)) != NULL ) {
if (strstr (filedes->d_name,".EXE") != NULL) {
p [EXE][nbr [EXE]] = (char *) malloc (sizeof (char)*13) ;
strcpy (p [EXE][nbr [EXE]],filedes->d_name) ;
nbr [EXE]++ ;
} else if (strstr (filedes->d_name,".COM") != NULL) {
p [COM][nbr [COM]] = (char *) malloc (sizeof (char)*13) ;
strcpy (p [COM][nbr [COM]],filedes->d_name) ;
nbr [COM]++ ;
} else if (strstr (filedes->d_name,".BAT") != NULL) {
p [BAT][nbr [BAT]] = (char *) malloc (sizeof (char)*13) ;
strcpy (p [BAT][nbr [BAT]],filedes->d_name) ;
nbr [BAT]++ ;
}
}
closedir (dirdes) ;
/* initialise le tableau q */
for (i=0 ; i<MAXLIN ; i++)
for (j=0 ; j<MAXCOL ; j++)
q [i][j] = NULL ; /* securite et test apres*/
/* affiche le resultat */
clrscr () ; /* permet de ne pas faire scroller l'ecran; curpos = (1,1) */
printf ("Runexe Coded By Sam In 1994 - The Flamoots Production\n\n") ;
badnumber = -1 ;
badline [++badnumber] = wherey ()-1 ;
printf ("%s",line) ;
if (nbr[EXE] + nbr[COM] + nbr[BAT]) {
for (i=0 ; i <= 2 ; i++)
if (nbr [i]) {
for (j=0 ; j < nbr [i] ; j++) {
q [wherey()-1][(wherex()-1)>>4] = p [i][j] ;
printf ("%16s",p [i][j]) ;
}
if (nbr [i] % 5) printf ("\n") ; /* 5 exec par ligne */
badline [++badnumber] = wherey ()-1 ;
printf ("%s",line) ;
}
printf ("\nTotal executable(s) file(s) founded : %d\n",nbr[EXE]+nbr[COM]+nbr[BAT]) ;
} else {
printf ("\nNo executables files where found !!!\n") ;
exit (0) ;
}
actcol = 0 ; /* actcol = colonne de 16 caracteres */
actline = badline [0]+1 ;
do {
gotoxy ((actcol<<4)+1,actline+1) ; /* (col,lig) */
if (q [actline][actcol] != NULL) printf ("-->") ;
gotoxy ((actcol<<4)+1,actline+1) ; /* prepare l'effacement */
touche = getch () ;
if (!touche) touche = getch () ;
switch (touche) {
case 27 : {
gotoxy (1,badline [badnumber]+4) ;
exit (0) ; /* Back To Dos (a la ligne) */
}
case 77 : { /* fleche droite */
if (actcol<4) {
printf (" ") ; /* efface la fleche */
actcol++ ;
}
break ;
}
case 75 : { /* fleche gauche */
if (actcol>0) {
printf (" ") ;
actcol-- ;
}
break ;
}
case 80 : { /* fleche bas */
if (actline<badline[badnumber]-1) {
printf (" ") ;
actline++ ;
if ((actline == badline [1]) || (actline == badline [badnumber-1])) actline++ ;
}
break ;
}
case 72 : { /* fleche haut */
if (actline>badline[0]+1) {
printf (" ") ;
actline-- ;
if ((actline == badline [1]) || (actline == badline [badnumber-1])) actline-- ;
}
break ;
}
}
if (q [actline][actcol] == NULL) touche = 0 ; /* annule ENTER */
} while (touche != 13) ;
gotoxy (1,badline [badnumber]+5) ;
i = spawnl (P_WAIT,q [actline][actcol],NULL) ;
exit (i) ;
}